~function(){
    //curEle是当前需要移动的元素，target是一个对象，
    //{left:xxx,top:xxx,right:xxx,width:xxx},duration:运动的总时间
    
    function moveAllDeraction(curEle,target,duration){
        curEle.timer = null;
        window.clearInterval(curEle.timer);

        var curPosition = {};
        for(var key in target){
            if(target.hasOwnProperty(key)){
                curPosition[key] = window.getComputedStyle(curEle,null)[key];
            }
        }

        console.log(curPosition);
        var changeEle = {

        };
        for(var key in target){
            if(target.hasOwnProperty(key)){
                changeEle[key] = target[key] - parseFloat(curPosition[key]);

            }
        }
        console.log(changeEle);
        var step = {};
        for(var key in target){
            if(target.hasOwnProperty(key)){
                step[key] = changeEle[key]/duration * 10;
            }
        }

        console.log(step);
        curEle.timer = window.setInterval(function(){
            var i = 0;
            for(var key in target){
                i++;
                
                if(target.hasOwnProperty(key)){
                    
                    curPosition[key] = parseFloat(curPosition[key]) + step[key];
                    
                    if(step[key] > 0){
                        if((curPosition[key] - target[key]) >= 0){
                            
                            curPosition[key] = target[key];
                            
                            curEle.style[key] = curPosition[key] + 'px';
                            if(i==Object.keys(target).length){
                                console.log(i);
                                window.clearInterval(curEle.timer);
                                return;
                            }
                        }
                    }else{
                        if((curPosition[key] - target[key]) <= 0){
                            curPosition[key] = target[key];
                            
                            curEle.style[key] = curPosition[key] + 'px';
                            if(i==Object.keys(target).length){
                                
                                window.clearInterval(curEle.timer);
                                return;
                            }
                        }
                    }
                    
                    curEle.style[key] = curPosition[key] + 'px';
                }
            }
            
        },10);
        

    }
    moveAllDeraction(box,{
        left:1400,
        top:900,
        width:5,
        height:5
    },500);
    return {
        moveAllDeraction:moveAllDeraction
    }

}();